home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / mail110 / main.c < prev    next >
C/C++ Source or Header  |  1994-02-20  |  5KB  |  241 lines

  1. //=========================================================
  2. //
  3. //    main.c
  4. //
  5. //    Simple Unix-style mailer for use with ka9q/DIS
  6. //
  7. //=========================================================
  8.  
  9. char VERSION[]=
  10. "MAILER $Revision: 1.10 $ $Date: 1994/02/20 19:13:16 $";
  11.  
  12. static char rcsid[]=
  13. "$Id: main.c,v 1.10 1994/02/20 19:13:16 gbj Exp user $";
  14.  
  15. /*
  16. $Log: main.c,v $
  17.  * Revision 1.10  1994/02/20  19:13:16  gbj
  18.  * Added mail aliasing.
  19.  *
  20.  * Revision 1.9  1994/02/14  23:35:06  gbj
  21.  * Incorporated Alec Jones's mods to log outgoing mail.
  22.  * New module log.c
  23.  * Changed modules init.c and mail.c
  24.  *
  25.  * Revision 1.8  1994/02/12  01:28:38  gbj
  26.  * Display mailbox index before each command request.
  27.  * When the index is displayed, display cmsg-8 to cmsg-8+16, if cmsg-8
  28.  * is less than zero, display 0 to 16.
  29.  * Enabled blinking cursor.
  30.  *
  31.  * Revision 1.7  1994/02/08  23:32:02  gbj
  32.  * First public release.
  33.  *
  34.  * Revision 1.6  1994/02/08  23:30:28  gbj
  35.  * New function: read next unread message.
  36.  *
  37.  * Revision 1.5  1994/02/08  22:01:42  gbj
  38.  * Still fixing up version keywords...
  39.  *
  40.  * Revision 1.4  1994/02/08  22:00:24  gbj
  41.  * Fixup version keywords
  42.  *
  43.  * Revision 1.3  1994/02/08  21:56:36  gbj
  44.  * Added version variable.
  45.  *
  46.  * Revision 1.2  1994/02/08  03:20:50  gbj
  47.  * Made Id keyword a static char so that Ident can display it.
  48.  *
  49.  * Revision 1.1  1994/02/08  03:15:10  gbj
  50.  * Initial revision
  51.  *
  52. */
  53.  
  54. // Set plenty of stack
  55. unsigned long _STACK=32768L;
  56.  
  57.  
  58. #include "mailer.h"
  59.  
  60. void main(void)
  61. {
  62.     int res;
  63.     int msgno;
  64.     COMMAND cmd;
  65.     char xuser[128], xfile[128];
  66.     
  67.     init(VERSION);
  68.     res=loadix(user);
  69.     if (res == 3) 
  70.     {
  71.         fprintf(stderr," loadix returned %d\n", res);
  72.         exit(res);
  73.     }
  74.     
  75.     if (res == 1 || res == 2)
  76.     {
  77.         cmsg=-1;
  78.         maxmsgno=-1;
  79.     }
  80.     else
  81.         cmsg=0;
  82.     
  83.     msgno=cmsg;
  84.     *xuser='\0';
  85.     *xfile='\0';
  86.     cmd=BAD;
  87.     
  88.     Cursconf(1, 0);                        // Show cursor
  89.     Cursconf(2, 0);                        // Make it blink
  90.     while (cmd != QUITX && cmd != QUIT)
  91.     {
  92.         if (cmsg-8 < 0)
  93.             showix(0, cmsg);
  94.         else
  95.             showix(cmsg-8, cmsg);         
  96.  
  97.         cmd=getcmd(&msgno, xuser, xfile);
  98.     
  99.         switch (cmd)
  100.         {
  101.             case DELETE:
  102.                 if (maxmsgno != -1)    
  103.                     mark(msgno, TRUE); 
  104.                 break;
  105.             
  106.             case MAIL:
  107.             case MAILFILE:    
  108.                 mailto(xuser, xfile); 
  109.                 break;
  110.             
  111.             case SAVE:        
  112.                 if (maxmsgno != -1)
  113.                     saveto(xfile, TRUE); 
  114.                 break;
  115.              
  116.              case WRITE:        
  117.                 if (maxmsgno != -1)
  118.                     saveto(xfile, FALSE); 
  119.                 break;
  120.              
  121.              case REPLY:        
  122.                 if (maxmsgno != -1)
  123.                     replyto(msgno); 
  124.                 break;
  125.              
  126.              case FORWARD:    
  127.                 if (maxmsgno != -1)
  128.                     forwardto(msgno, xuser);
  129.                 break;
  130.              
  131.              case UNDELETE:    
  132.                 if (maxmsgno != -1)
  133.                     mark(msgno, FALSE); 
  134.                 break;
  135.              
  136.              case NEXT:        
  137.                 if (maxmsgno != -1)
  138.                     bump(1); 
  139.                 break;
  140.              
  141.              case PREV:        
  142.                 if (maxmsgno != -1)
  143.                     bump(-1); 
  144.                 break;
  145.              
  146.              case READ:
  147.              case PRINT:        
  148.                 if (maxmsgno != -1)
  149.                 {
  150.                     cmsg=msgno;
  151.                     showmsg(msgno);
  152.                     mailix[cmsg].rflag=1;
  153.                 } 
  154.                 break;
  155.              
  156.              case HEADER:    
  157.                 if (maxmsgno != -1)
  158.                     showix(msgno, cmsg); 
  159.                 break;
  160.              
  161.              case LIST:        
  162.                 listqueue(); 
  163.                 break;
  164.              
  165.              case NEW:        
  166.                 newmbox(xfile); 
  167.                 break;
  168.              
  169.              case QUITX:        
  170.                 quit(FALSE); 
  171.                 break;
  172.              
  173.              case QUIT:        
  174.                 if (maxmsgno != -1)
  175.                     quit(TRUE); 
  176.                 else
  177.                     quit(FALSE);
  178.                 break;
  179.              
  180.              case HELP:        
  181.                 help(); 
  182.                 break;
  183.             
  184.             case UNREAD:
  185.                 if (msgno != -1)
  186.                 {
  187.                     int ix;
  188.                     for (ix=0; ix <= maxmsgno; ix++)
  189.                     {
  190.                         if (mailix[ix].rflag != 1)
  191.                         {
  192.                             showmsg(ix);
  193.                             mailix[ix].rflag=1;
  194.                             cmsg=ix;
  195.                             break;
  196.                         }
  197.                     }
  198.                 }
  199.                 break;    
  200.              
  201.              default:        
  202.                 help();
  203.                 break;
  204.         }
  205.     }
  206.                  
  207.     exit(0);
  208. }
  209.  
  210. void help(void)
  211. {
  212.     printf("\nCOMMANDS AVAILABLE:\n");
  213.     printf("m user          send mail to a user\n");
  214.     printf("t user file     send mail from a file to a user\n");
  215.     printf("f user [msg]    forward message to a user\n");
  216.     printf("r [msg]         reply to a message\n");
  217.     printf("ENTER           show next unread message\n");
  218.     printf("msg             show message\n");
  219.     printf("p [msg]         show message\n");
  220.     printf("s [file]        save message in a file\n");
  221.     printf("w [file]        save message without headers\n");
  222.     printf("d [msg]         mark message as deleted\n");
  223.     printf("u [msg]         mark message as undeleted\n");
  224.     printf("+               goto next message\n");
  225.     printf("-               goto previous message\n");
  226.     printf("h [msg]         list headers starting at msg\n");
  227.     printf("n mbox          change mailbox\n");
  228.     printf("l               list unsent messages\n");
  229.     printf("x               exit without updating mailbox\n");
  230.     printf("q               exit with updating\n");
  231.     printf("?               This help text\n");
  232.     printf("[msg]  - message number, default to current message\n");
  233.     printf("[file] - file name, default to mbox.txt\n");
  234.     printf("mbox   - mailbox name\n");
  235.     printf("Press a key...");
  236.     getch();
  237.     putchar('\n');
  238.     return;
  239. }
  240.      
  241.